﻿using Kaiser.Modules.Cubic.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kaiser.Modules.Cubic.Services.Impl
{
    public class ProductService : IProductService
    {
        private readonly IProductRepositorie _productRepositorie;

        public ProductService(IProductRepositorie productRepositorie)
        {
            _productRepositorie = productRepositorie;
        }

        public Models.DataGrid<DomainModel.Product.ProductDetail> SearchProduct(ViewModel.ProductSearch search, Models.PagingInfo pageinfo)
        {
            try
            {
                return _productRepositorie.SearchProduct(search ,pageinfo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public IList<DomainModel.Product.Photo> GetProductPhotoList(string objectID)
        {
            throw new NotImplementedException();
        }

        public void Insert(DomainModel.Product.ProductDetail model)
        {
            try
            {
                _productRepositorie.Insert(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void Update(DomainModel.Product.ProductDetail model)
        {
            try
            {
                _productRepositorie.Update(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public int Delete(object primaryId)
        {
            try
            {
                return _productRepositorie.Delete(primaryId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public DomainModel.Product.ProductDetail Get(object primaryId)
        {
            try
            {
               return _productRepositorie.Get(primaryId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public int DeleteList(IList<string> ids)
        {
            throw new NotImplementedException();
        }


        public void InsertProductPhoto(DomainModel.Product.Photo model)
        {
            try
            {
                  _productRepositorie.InsertProductPhoto(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void UpdateProductPhoto(DomainModel.Product.Photo model)
        {
            try
            {
                _productRepositorie.UpdateProductPhoto(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void DelProductPhoto(string id)
        {
            try
            {
                _productRepositorie.DelProductPhoto(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public Models.DataGrid<DomainModel.Product.Photo> SearchProductPhoto(string productId,Models.PagingInfo pageinfo )
        {
            try
            {
                return _productRepositorie.SearchProductPhoto(productId,pageinfo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public DomainModel.Product.Photo GetProductPhoto(string id)
        {
            try
            {
                return _productRepositorie.GetProductPhoto(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


       
     
    }
}
